{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
  <!--主要内容开始-->
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
      <!--树状图-->
        <section class="col-lg-2 connectedSortable" style="padding-right:0;">
         <div class="sidebar" style="background-color:#fff; padding-bottom:0px;">
             <ul class="sidebar-menu" id="chan">
					{%foreach from=$class_lists key=key item=value%}
                    <li class="treeview {%if $key==$class_data.grade_id%}active{%/if%}" >
                      <a href="#">
                        <i class="glyphicon glyphicon-align-left"></i> <span>{%$value.grade_name%}</span> <i class="fa fa-angle-left pull-right"></i>
                      </a>
                          <ul class="treeview-menu" style="background-color:#fff;">
							{%foreach from=$value.class key=k item=v%}
                            <li {%if $v.class_id==$class_data.class_id%}class="active"{%/if%}><a href="index.php?a=score.subject&class_id={%$v.class_id%}"><i class="fa fa-angle-right"></i>  {%$v.class_name%}</a></li>
							{%/foreach%}
                          </ul>
                     </li>
					{%/foreach%}
              </ul>
            </div>
        </section>
        <!--树状图结束-->
        <section class="col-lg-10 connectedSortable">
         <div class="box box-default box-solid">
             <form action="" method="post">	
                <div class="box-header with-border">
                    <span class="fa fa-edit (alias)" style="float:left; font-size:18px; padding-top:3px; color:#3c8dbc;" ></span>
                    <p class="box-title">{%$class_data.class_name%}成绩统计科目设置（配置好一个班级后可复制给其他班级）</p>
                </div>
                <div class="box-body">
                      <div class="form-group">
						  <label class="col-md-2 text-right">
							   综合科目设置：
						  </label>
						  <div class="input-group col-md-6 col-sm-12 col-xs-12">
							   <span class="btn btn-default btn-sm" data-toggle="modal" data-target="#myModal">添 加</span>
                               <span class="text-info">非必要可不设置</span>
						  </div> 
				      </div>
                      <p class="col-md-offset-2" id="summary">
							   {%foreach from=$set.score_group key=key item=value%}
							   {%$key%}: {%$value%} <a onclick="if(confirm('警告！确认删除信息?')==false)return false;" href="index.php?a=score.groupdel&class_id={%$class_data.class_id%}&group_name={%$key%}">删除</a><br/>
							   {%/foreach%}
					 </p>
                      
                      <div class="form-group" style="margin-bottom:6px;">
						  <label class="col-md-2 text-right" style="padding-left:0;">
							   计入总分的学科：
						  </label>
						  <div class="input-group col-sm-10 col-xs-12">
						  {%foreach from=$subject_lists key=key item=value%}
							    <label class="choice"><input type="checkbox" name="score_total[]" value="{%$value.subject_id%}" {%if $value.is_total=='1'%}checked{%/if%}> {%$value.subject_name%}</label>
						  {%/foreach%}
						  </div> 
				      </div> 
                      <p class="col-md-offset-2 text-info">说明：没计入总分的学科可单独录入成绩，只是不参加总分累加。</p> 
                       <div class="form-group">
						  <label class="col-md-2 text-right">
							   报表顺序设置：
						  </label>
						  <div class="col-md-10 col-sm-12 col-xs-12">
                               <div style="width:100%; overflow-x:scroll;">
                                   <table class="table table-bordered">
                                       <tr>
								   {%foreach from=$subject_lists key=key item=value%}
                                           <td>{%$value.subject_name%}</td>
									{%/foreach%}
                                           {%foreach from=$set.score_group key=key item=value%}
                                           <td>{%$key%}</td>
                                           {%/foreach%}
                                       </tr>
                                       <tr> 
								   {%foreach from=$subject_lists key=key item=value%}
                                           <td><input type="text" name="score_order_{%$value.subject_id%}" value="{%$value.score_order%}" size="4"></td>
									{%/foreach%}
								   {%foreach from=$group_order key=key item=value%}
								   <td><input type="text" name="score_order_{%$key%}" value="{%$value%}" size="4"></td>
								   {%/foreach%}
                                       </tr>
                                   </table>
                               </div>
						  </div> 
				      </div> 
                      <div class="form-group" style="margin-bottom:6px;">
						  <label class="col-md-2 text-right" style="padding-left:0;">
							   选择复制班级：
						  </label>
						  <div class="col-md-10 col-sm-10 col-xs-12">
							       <ul id="treeDemo" class="ztree"></ul>
                                   <div style="display:none;">
                                        被勾选时：<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
                                        <input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
                                        取消勾选时：<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
                                        <input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
                                    </div>
                          </div> 
                      </div> 
				</div><!--box-body -->
						<div id="hiddenBox"></div>
                <div class="box-footer text-center">
                    <button type="submit" class="btn btn-primary " onclick="c();">  保 存</button>
                </div>
              </form>
           </div><!--box box-default box-solid-->
         </section>   
        </div><!--row-->
    </section>
 </div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
<!--弹出层-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <form name="form2" action="index.php?a=score.groupadd" method="post" id="dlg_form">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">综合科目设置</h4>
      </div>
      <div class="modal-body">
             <div class="form-group">
                      <label class="col-md-3 text-right">
                           综合科目名称：
                      </label>
                      <div class="input-group col-sm-9 col-xs-12">
                            <input type="text" value="" name="group_name">
                      </div> 
			</div> 
            <div class="form-group" style="margin-bottom:6px;">
                  <label class="col-md-3 text-right">
                       包含学科：
                  </label>
                  <div class="input-group col-sm-9 col-xs-12">
				  {%foreach from=$subject_lists key=key item=value%}
                        <label class="choice"><input type="checkbox" name="score_group[]" value="{%$value.subject_id%}"> {%$value.subject_name%}</label>
				  {%/foreach%}
                  </div> 
             </div>    
      </div>
      <div class="modal-footer">
		<input type="hidden" name="class_id" value="{%$class_data.class_id%}">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="submit" class="btn btn-primary">确定</button>
      </div>
    </div>
    </form>
  </div>
</div>
<!--弹出层-->
<!-- jQuery 2.2.0 -->

<script type="text/javascript" src="static/js/jquery.ztree.core.js"></script><!--树形-->
<script type="text/javascript" src="static/js/jquery.ztree.excheck.js"></script><!--树形-->
<script type="text/javascript">
		var setting = {
			check: {
				enable: true,	
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		var zNodes =[
		{%foreach from=$class_lists key=key item=value%}
			{ id:"g{%$key%}", pId:0, name:"{%$value.grade_name%}",},
			{%foreach from=$value.class key=k item=v%}
			{ id:"c{%$v.class_id%}", pId:"g{%$key%}", name:"{%$v.class_name%}",},
			{%/foreach%}
		{%/foreach%}
		];
		var code;
		
		function setCheck() {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			py = $("#py").attr("checked")? "p":"",
			sy = $("#sy").attr("checked")? "s":"",
			pn = $("#pn").attr("checked")? "p":"",
			sn = $("#sn").attr("checked")? "s":"",
			type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code) code = $("#code");
			code.empty();
			code.append("<li>"+str+"</li>");
		}
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);
		});
function c()
{
	var delidID = "";
	var zTree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="to_class[]" value="'+zTree[i].id+'">');
	}

} 	
</script>
